package com.example.springboot.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class HelloController {
    @RequestMapping("/hello")
    @ResponseBody
    public String testHello(String name){
        return "Hello "+name;
    }
    @RequestMapping("/hello-exception")
    @ResponseBody
    public String helloException(@RequestParam(value = "number") String number){
        if(null == number || "".equals(number))throw new NullPointerException();
        Integer integer = Integer.valueOf(number);
        return "数字：" + integer;
    }
}
